package apps.softtech.fastmarket.model;

import android.content.ContentValues;
import android.database.Cursor;

public class ChatLog {

	public static String TABLE_NAME = "ChatLog";
	public static final String ID = "id";
	public static final String CHAT_LOG_ID = "st_ChatLogId";
	private int chatLogId;

	public static final String CONTENT = "st_Content";
	private String content;

	public static final String CREATED_DATE = "st_CreatedDate";
	private String createdDate;

	public static final String FROM_USER_ID = "st_FromUserId";
	private int fromUserId;

	public static final String TO_USER_ID= "st_ToUserId";
	private int toUserId;

	public static final String TYPE = "st_Type";
	private int type;

	public ChatLog() {
		super();
		// TODO Auto-generated constructor stub
	}

	public ChatLog(int chatLogId, String content, String createdDate,
			int fromUserId, int toUserId, int type) {
		super();
		this.chatLogId = chatLogId;
		this.content = content;
		this.createdDate = createdDate;
		this.fromUserId = fromUserId;
		this.toUserId = toUserId;
		this.type = type;
	}

	public ChatLog(String content, String createdDate, int fromUserId,
			int toUserId, int type) {
		super();
		this.content = content;
		this.createdDate = createdDate;
		this.fromUserId = fromUserId;
		this.toUserId = toUserId;
		this.type = type;
	}

	public int getChatLogId() {
		return chatLogId;
	}

	public void setChatLogId(int chatLogId) {
		this.chatLogId = chatLogId;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(String createdDate) {
		this.createdDate = createdDate;
	}

	public int getFromUserId() {
		return fromUserId;
	}

	public void setFromUserId(int fromUserId) {
		this.fromUserId = fromUserId;
	}

	public int getToUserId() {
		return toUserId;
	}

	public void setToUserId(int toUserId) {
		this.toUserId = toUserId;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}


	/**
	 * get value of ChatLog
	 * @return values
	 */
	public ContentValues getValueChatLog(){
		ContentValues values = new ContentValues();
		values.put(CONTENT, this.getContent());
		values.put(CREATED_DATE, this.getCreatedDate());
		values.put(FROM_USER_ID, this.getFromUserId());
		values.put(TO_USER_ID, this.getToUserId());
		values.put(TYPE, this.getType());
		
		return values;
	}

	public void setValueFromCursor(Cursor c) {
		
		if (c.getColumnIndex(CHAT_LOG_ID) >= 0) {
			setChatLogId(c.getInt(c.getColumnIndex(CHAT_LOG_ID)));
		}
		if (c.getColumnIndex(CONTENT) >= 0) {
			setContent(c.getString(c.getColumnIndex(CONTENT)));
		}
		if (c.getColumnIndex(CREATED_DATE) >= 0) {
			setCreatedDate(c.getString(c.getColumnIndex(CREATED_DATE)));
		}
		if (c.getColumnIndex(FROM_USER_ID) >= 0) {
			setFromUserId(c.getInt(c.getColumnIndex(FROM_USER_ID)));
		}
		if (c.getColumnIndex(TO_USER_ID) >= 0) {
			setToUserId(c.getInt(c.getColumnIndex(TO_USER_ID)));
		}
		if(c.getColumnIndex(TYPE)>=0){
			setType(c.getInt(c.getColumnIndex(TYPE)));
		}
	}

}
